﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Server
{

    public partial class Caidat : Form
    {
        public Caidat()
        {
            InitializeComponent();
        }

        #region "Biến"
        public delegate void SaveConfigHander();
        public event SaveConfigHander SaveConfigEvent;

        #endregion

        #region "Sự kiện"
        /// <summary>
        /// Sự kiện load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Caidat_Load(object sender, EventArgs e)
        {
            CConfig config = new CConfig();
            try
            {
                txtPort.Value = decimal.Parse(config.Port.ToString());
            }
            catch (Exception c)
            {

            }
        }
        /// <summary>
        /// Sự kiện lưu config
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void Caidat_FormClosing(object sender, FormClosingEventArgs e)
        {
           
            try
            {
                CConfig config = new CConfig();
                int port = int.Parse(txtPort.Value.ToString());
                config.GhiFileConfig(port);
            }
            catch (Exception c)
            {
                CConfig config = new CConfig();
                config.GhiFileConfig(12121);
            }
        }
        #endregion




    }
}
